package com.lagou.web.servlet;

import com.alibaba.fastjson.JSON;
import com.lagou.base.BaseServlet;
import com.lagou.pojo.Course;
import com.lagou.service.CourseService;
import com.lagou.service.Impl.CourseServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/course")
public class CourseServlet extends BaseServlet {
    public void findCourseList(HttpServletRequest req, HttpServletResponse resp){
        try {
       CourseService cs = new CourseServiceImpl();
        List<Course> courseList = cs.findCourseList();
        String s = JSON.toJSONString(courseList);

            resp.getWriter().println(s);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
